package struts.common;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

import struts.form.ActionForm;

public class FullForm {

	public FullForm() {
	}

	public static ActionForm full(String formClass,HttpServletRequest request){
		
		ActionForm form = null;
		try {
			@SuppressWarnings("rawtypes")
			Class clazz = Class.forName(formClass);
			form = (ActionForm) clazz.newInstance();
			Field [] field_ar = clazz.getDeclaredFields();
			for (Field field : field_ar) {
				field.setAccessible(true);
				field.set(form, request.getParameter(field.getName()));
				field.setAccessible(false);
			}
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("严重: Form 装载失败!.......");
		}
		return form;
	}
}
